gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\generalp\ppatterns.m
function ppatterns(data,arg1,arg2) % PPATTERNS plots points in 2D feature space. % % ppatterns(data,labels,psize) plots patterns as points % in 2D and distinguishes them according to the given % labels. If psize defined then the points will be of % this size. % % ppatterns(data,str,psize) plots patterns as points % with marker and color defined by the argument str. % See 'help plot' for more info on this argument. % % Input: % data [2 x L] matrix containing L patterns in 2D space. % labels [1 x L] labels of these paterns (1, 2, ...). % str [string] defines marker and color of points (patterns). % psize [int] size of points. % % % Example: % % Logical function AND % data = [0 1 0 1; % 0 0 1 1]; % labels=[1 1 1 2]; % % ppatterns(data, labels); % % Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac % (c) Czech Technical University Prague, http://cmp.felk.cvut.cz % % Modifications % 21-october-2001, V. Franc % 16-april-2001, V. Franc % 24. 6.00 V. Hlavac, comments polished. if nargin == 1 | isstr(arg1), if nargin >= 2, h = plot(data(1,:),data(2,:), arg1 ); if nargin >=3, set(h,'MarkerSize',arg2); end else h = plot(data(1,:),data(2,:), marker(1)); set(h, 'color',color(1)); end elseif nargin >= 3 & isstr(arg2) & strcmpi(arg2,'num'), labels = arg1; psize = 10; oldhold = ishold; hold on; for i = 1:max(labels), inx = find(labels==i); if ~isempty(inx), h = plot(data(1,inx),data(2,inx),'o'); set(h,'Color',color(i)); set(h,'MarkerSize',psize); h = text(data(1,inx),data(2,inx),num2str(i)); set(h,'HorizontalAlignment','center'); set(h,'VerticalAlignment','middle'); set(h,'Color',color(i)); set(h,'FontSize',psize-1); end end if oldhold, hold on; else hold off; end else labels = arg1; if nargin >= 3, psize = arg2; end oldhold = ishold; hold on; for i = 1:max(labels), inx = find(labels==i); if ~isempty(inx), h = plot(data(1,inx),data(2,inx),marker(i)); set(h,'Color',color(i)); if nargin >= 3, set(h,'MarkerSize',psize); end end end if oldhold, hold on; else hold off; end end return; DIM=size(X,1); K=size(X,2); if nargin < 2 | isempty(I), I=ones(1,size(X,2)); end % sets default marker size if nargin < 3 | isempty(msize), msize=5; end % sets default 'EraseMode' if nargin < 4 | isempty(emode), emode='none'; end if nargin < 5, % plot points for i=1:K, % plots the point colored according to the class number line(X(1,i),X(2,i),'Color',color(I(i)),... 'LineStyle','none',... 'Marker',marker(I(i)),... 'EraseMode',emode,... 'MarkerSize',msize); end else for i=1:K, % plots the point colored according to the class number line(X(1,i),X(2,i),'Color',col,... 'LineStyle','none',... 'Marker',marker(I(i)),... 'EraseMode',emode,... 'MarkerSize',msize); end end return